﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Admin/BaseMaster/Pages.Master" AutoEventWireup="true" CodeBehind="UserManage.aspx.cs" Inherits="Liu_Project.Web.Admin.Pages.Personal.EntUser.UserManage" %>

<asp:Content ID="Content1" ContentPlaceHolderID="baseTitle" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="baseHead" runat="server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="baseContent" runat="server">
    <div class="layui-row">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body">
                    <div class="layui-row">
                        <form class="layui-form layui-form-pane" lay-filter="searchForm">
                            <div class="layui-form-item">
                                <div class="layui-inline">
                                    <label class="layui-form-label" style="padding: 9px 0; width: 100px">用户编号/名称</label>
                                    <div class="layui-input-block">
                                        <input type="text" name="UserNo" placeholder="用户编号/名称" autocomplete="off" class="layui-input" maxlength="18" data-options='{ "Field":"A.UserNo,A.UserName","Method":"%","Logic":"And","SubLogic":"OR","IsNoSubField":"false"}'>
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <label class="layui-form-label">手机号</label>
                                    <div class="layui-input-block">
                                        <input type="text" name="Phone" placeholder="请输入手机号" autocomplete="off" class="layui-input" maxlength="18" data-options='{ "Field":"A.Phone","Method":"%","Logic":"And","SubLogic":"OR","IsNoSubField":"true"}'>
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <label class="layui-form-label">邮箱</label>
                                    <div class="layui-input-block">
                                        <input type="text" name="Email" placeholder="请输入邮箱" autocomplete="off" class="layui-input" maxlength="18" data-options='{ "Field":"A.Email","Method":"%","Logic":"And","SubLogic":"OR","IsNoSubField":"true"}'>
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <button class="layui-btn" lay-submit lay-filter="search"><i class="layui-icon  layui-icon-search"></i></button>
                                </div>
                            </div>
                        </form>
                    </div>
                    <table id="tableGrid" lay-filter="tbGrid" class="table_margin_0"></table>
                </div>
            </div>
        </div>
    </div>

     <script type="text/html" id="txtLastLoginTime">
        <div>{{layui.util.toDateString(d.LastLoginTime)}}</div>
    </script>
    <%--<script type="text/html" id="checkboxAdmin">
        <input type="checkbox" name="IsAdministrator" value="{{d.IsAdministrator}}" lay-skin="switch" lay-text="开启|关闭" disabled {{ d.IsAdministrator ? 'checked' : '' }}>
    </script>--%>
     <script type="text/html" id="checkboxIsVisiable">
        <input type="checkbox" name="IsVisiable" value="{{d.IsVisiable}}" lay-skin="switch" lay-text="正常|禁用" disabled {{ d.IsVisiable ? 'checked' : '' }}>
    </script>
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="baseScript" runat="server">
    <script>
        ; !function () {
            var tableOption = {
                elem: '#tableGrid',
                url: bootPATH + '/Admin/Handler/BaseHand/UserRoleHand.ashx',
                where: { act: "LoadPage" },
                height: 'full-88',//表格容器距离浏览器顶部和底部的距离“和”，加上面板上下内边距40px
                cols: [[
                    //{ type: 'checkbox', fixed: true },
                    {
                        fixed: true, title: '<input type="checkbox" name="layTableCheckbox" lay-skin="primary" lay-filter="layTableAllChoose">', width: 48, templet: '#myCheckbox'
                    },
                    { type: 'numbers', title: '序号', fixed: true },
                    { field: 'UserNo', title: '用户编号', minWidth: 80, sort: true, fixed: true },
                    { field: 'UserName', title: '用户名称', minWidth: 120, sort: true },
                    { field: 'Img', title: '头像', width: 80, sort: true, templet: '<div><img class="layui-nav-img" src="{{d.Img}}" /></div>' },
                    //{ field: 'IsAdministrator', title: '超级管理员', minWidth: 80, sort: true, templet: '#checkboxAdmin' },
                    { field: 'Phone', title: '手机号码', minWidth: 120, sort: true },
                    { field: 'Email', title: '邮箱', minWidth: 160, sort: true },
                    { field: 'IsVisiable', title: '状态', minWidth: 60, sort: true, templet: '#checkboxIsVisiable' },
                    { field: 'LastLoginTime', title: '最后登录时间', minWidth: 160, sort: true, templet: '#txtLastLoginTime' },
                    { field: 'CreateTime', title: '创建时间', minWidth: 160, sort: true, templet: '#txtCreateTime' },
                    { field: 'CreateUserName', title: '创建人', minWidth: 120, sort: true, templet: '#txtCreateUserName' },
                    { field: 'UpdateTime', title: '最后修改时间', minWidth: 160, sort: true, templet: '#txtUpdateTime' },
                    { field: 'UpdateUserName', title: '最后修改人', minWidth: 120, sort: true, templet: '#txtUpdateUserName' }
                ]],
            };

            table_render(tableOption);//加载表格数据

            layui.table.on('toolbar(tbGrid)', function (obj) {
                var checkData = layui.table.checkStatus(obj.config.id);
                if ((obj.event == "Edit" || obj.event == "Delete") && checkData.data.length == 0) {
                    top.layer.msg('请选择数据,再操作!', function () { });
                    return;
                }
                switch (obj.event) {
                    case 'Add':
                    case 'Edit':
                        {
                            layer.open({
                                type: 2,
                                id: obj.event == 'Edit' ? checkData.data[0].UserId : 0,
                                title: obj.event == 'Edit' ? checkData.data[0].UserNo : "新增用户",
                                content: 'UserManageDetail.aspx',
                                //shade: false,
                                maxmin: true,
                                area: obj.event == 'Edit' ? ['600px', '650px'] : ['600px', '650px'],
                                zIndex: layer.zIndex,
                                success: function (layero, index) {
                                    layer.setTop(layero);
                                    var iframeWindow = window['layui-layer-iframe' + index];
                                    iframeWindow.setData(obj.event, obj.event == 'Edit' ? checkData.data[0] : {});
                                },
                                end: function (layero, index) {
                                    layui.table.reload("tableGrid");
                                }
                            });
                        }
                        break;
                    case 'Delete':
                        top.layer.confirm('确定删除吗?', { icon: 3, title: '提示' }, function (index) {
                            let id_Arr = [];
                            for (var i = 0; i < checkData.data.length; i++) {
                                id_Arr.push(checkData.data[i].UserId);
                            }
                            top.layer.load(1);
                            GetObjectInfoFunction_Async("Admin/Handler/BaseHand/UserRoleHand.ashx", {
                                "act": "Delete", "Data": id_Arr.toString()
                            }, function (result) {
                                top.layer.close(index);
                                top.layer.msg('删除成功');
                                layui.table.reload("tableGrid");
                            })
                        });
                        break;
                    case 'AuthorizeMenu':
                        {
                            layer.open({
                                type: 2,
                                id: checkData.data[0].UserId,
                                title: checkData.data[0].UserNo + "/" + checkData.data[0].UserName,
                                content: '../EntRole/AuthorizeMenu.aspx',
                                maxmin: true,
                                area: ['345px', '538px'],
                                btn: ['保存', '取消'],
                                success: function (layero, index) {
                                    var iframeWindow = window['layui-layer-iframe' + index];
                                    iframeWindow.setData("U", checkData.data[0].UserId);
                                },
                                yes: function (index, layero) {
                                    var iframeWindow = window['layui-layer-iframe' + index];
                                    iframeWindow.Save("U", checkData.data[0].UserId, index);
                                }
                            });
                        }
                        break;
                };
            });

            layui.form.on('submit(search)', function (data) {
                var where = getFilter(data);

                layui.table.reload("tableGrid", { where: { act: "LoadPage", DataWhere: where } })
                return false;
            });

        }();
    </script>
</asp:Content>
